package com.arc.state;

import arc.ArcBase;
import com.jme3.network.serializing.Serializable;

/**
 *
 * @author Adam
 */

@Serializable
public abstract class MessageState extends AbstractState{
    
    static final private byte[] data =   {
        (byte)0x10, //initialze
        (byte)0x21, //syn
        (byte)0x12, //ack
        (byte)0x03  //kill
    };
    
    public static final byte STATE_INITIALIZE = 0x0;
    public static final byte STATE_SYN        = 0x1;
    public static final byte STATE_ACK        = 0x2;
    public static final byte STATE_KILL       = 0x3;
    
    public MessageState()
    {     
        super(data);
    }
    
    abstract public void synLogic(ArcBase app, ArcBase.Type type, Object ... param);
    abstract public void ackLogic(ArcBase app, ArcBase.Type type, Object ... param);
    abstract public void initializeLogic(ArcBase app, ArcBase.Type type, Object ... param);
    abstract public void killLogic(ArcBase app, ArcBase.Type type, Object ... param);
    public void updateState(ArcBase app, ArcBase.Type type, Object[] params)
    {
        switch(getIndex())
        {
            case MessageState.STATE_INITIALIZE:
                initializeLogic(app, type);
                break;
            case MessageState.STATE_SYN:
                synLogic(app, type);
                break;
            case MessageState.STATE_ACK:
                ackLogic(app, type);
                break;
            case MessageState.STATE_KILL:
                killLogic(app, type);
                break;
        }
    }
    
}
